package test;


import com.example.utils.Config;
import com.example.utils.StringUtils;
import com.example.utils.image.AnimatedGifEncoder;
import com.example.utils.image.AutoPlayerImageThread;
import com.example.utils.image.HttpUtils;
import com.example.utils.json.Equipment;
import com.example.utils.json.EquipmentUtil;

import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.*;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class test {

    public static void main(String[] args) {
        /*String str="444.08500000000004";
        System.out.println(Double.parseDouble(str));
        System.out.println((int)Double.parseDouble(str));*/
//        String regx = "\\[CQ:image,file=(.*?)]";
//        String str = "测试哒哒哒哒哒哒多[CQ:image,file=6B6F82A38FDF58B303EFA15F88BCDE5C.jpg]";
        //String temp = str.replaceAll(regx,"[CQ:image,file="+ Config.REPLY_IMAGE_VALUE2+"$1]");
        //System.out.println(StringUtils.replaceMsgImageAddress(str,Config.REPLY_IMAGE_VALUE2));
        //System.out.println(temp);

        /*EquipmentUtil.initEquipment();
        List<Equipment> equipmentList = EquipmentUtil.getEquipmentList();
        Equipment equipment = equipmentList.get(20);
        Map<Integer, Equipment> relationEquipment = EquipmentUtil.getRelationEquipment(equipment, null);
        System.out.println(relationEquipment);*/
        System.out.println(isRe(new int[]{1,2,3}));;
    }

    /**使用Set集合特性判断int数组是否有重复值
     *
     * @param ins int数组
     * @return false 重复 true 不重复
     */
    public  static boolean isRe(int [] ins){
        Set<Integer> sets = new HashSet<>(ins.length);
        for (int i : ins) {
            sets.add(i);
        }
        return ins.length == sets.size();
    }

    public static void main23(String[] args) throws IOException {
        File zero = new File("d:677_.png");
        File full = new File("d:677_full_.png");
        File gif = new File("D:677_all.gif");
        BufferedImage z = ImageIO.read(zero);
        BufferedImage f = ImageIO.read(full);

        AnimatedGifEncoder e = new AnimatedGifEncoder();
        e.setRepeat(0);
        e.start("D:677_all.gif");
        e.setQuality(5);
        e.setDelay(3000); // 1 frame per sec
        e.addFrame(z);
        e.addFrame(f);
        e.setTransparent(new Color(255,255,255));
        e.finish();
    }



    public static void main2(String[] args) throws ExecutionException, InterruptedException, IOException {
       /* Runnable runnable = new AutoPlayerImageThread();
        new Thread(runnable).start();
        System.out.println("---");*/
        /*InputStream inputStream = HttpUtils.getInputStreamByGet("http://i.itpk.cn/api.php?question=123");
        byte[] bytes = new byte[0];
        bytes = new byte[inputStream.available()];
        inputStream.read(bytes);
        String str = new String(bytes);
        System.out.println(str);*/


        //System.out.println("[CQ:at,qq=2563038558]".replace( "[CQ:at,qq=2563038558]",""));

        /*BufferedImage src1 = ImageIO.read(new File("D:\\img\\5.png"));
        BufferedImage src2 = ImageIO.read(new File("D:\\img\\6.png"));
        //BufferedImage src3 = ImageIO.read(new File("c:/ship3.jpg"));
        AnimatedGifEncoder e = new AnimatedGifEncoder();
        e.setRepeat(0);
        e.start("D:\\img\\7.gif");
        e.setDelay(5000); // 1 frame per sec
        e.addFrame(src1);
        e.setDelay(5000);
        e.addFrame(src2);
        e.setDelay(5000);
        //  e.addFrame(src2);
        e.finish();*/

        //String str = "增加45(60)%常驻移速，在侦探/海盗少女中增加10(20)拾取半径；常驻移速加成＞125%时，根据超额百分比获得可额外增幅层数，关卡内每0.4(0.2)秒提升2%全伤害，最多125层";

      /*  String str = "今天我赚了100(200)%元，和朋友吃饭消费了0.5(1.0)%元，我今天还剩下95.5(199)%元,明天我可能就会有300%元，哈哈哈！";

        List<String> behindNums = new ArrayList<String>();

        final String pattern = "(([^\\d\\.]+)[(]([\\d\\.]+)[)])";
        final String pattern2 = "\\((.*?)\\)";
        Pattern p= Pattern.compile(pattern2);
        Matcher m=p.matcher(str);
        while(m.find()){
            behindNums.add(m.group().replace("(","").replace(")",""));
        }
        str = str.replaceAll(pattern2,"B");

        StringBuffer stringBuffer = new StringBuffer();
        int temp = -1;
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if(StringUtils.isNum(c)||c=='B'||c=='.'){
                String tempNum = "";
                boolean behindIsBrackets = false;
                for (int j = i; j < str.length(); j++) {
                    char x = str.charAt(j);
                    if(x=='.'||StringUtils.isNum(x)){
                        tempNum += x;
                    }else{
                        if(x=='B'){
                            i=j;
                            behindIsBrackets = true;
                            break;
                        }else{
                            System.out.println(x);
                            i=j-1;
                            break;
                        }

                    }
                }
                if(behindIsBrackets){
                    temp+=1;
                    stringBuffer.append("{").append(temp).append("}");
                }else{
                    stringBuffer.append(tempNum);
                }
            }else{
                stringBuffer.append(c);
            }
        }

        System.out.println(stringBuffer.toString());
        System.out.println(behindNums);
        System.out.println(MessageFormat.format(stringBuffer.toString(),behindNums.toArray()));
*/

      //String str = "唯一装备，携带时，其它来源的生命和弹药回复失效";
      String str2 = "唯一装备，携带时，其它来源的生命和弹药";
      System.out.println(str2.getBytes().length);
      char c = '3';
        System.out.println((c+"").getBytes().length);
    }
}
